#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int year = 0;
    int month = 0;
    int day = 0;
    int _month[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    int day_count = 0;
    scanf("%d %d %d", &year, &month, &day);
    if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
    {
        _month[2] = 29;
    }
    for (int i = 0;i < month;i++)
    {
        day_count += _month[i];
    }
    day_count += day;
    printf("%d", day_count);
    return 0;
}